/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * frmPenerimaanSupplier.java
 *
 * Created on Jan 25, 2012, 11:06:44 AM
 */
package SIMRS.Apotek.view;

import SIMRS.Apotek.sql.KoneksiDatabase;
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.text.DateFormat;
import usu.widget.Form;
import java.util.Calendar;
import java.util.Date;
import javax.swing.table.DefaultTableModel;

/**
 *
 * @author yunniie
 */
public class frmPenerimaanSupplier extends Form {
private static DefaultTableModel model;
Connection koneksi=KoneksiDatabase.getKoneksi();
    /** Creates new form frmPenerimaanSupplier */
    public frmPenerimaanSupplier() {
        initComponents();
   
        
        model=new DefaultTableModel();
        tblPenerimaanSupplier.setModel(model);
        model.addColumn("Kode Barang");
        model.addColumn("Nama Barang");
        model.addColumn("Jumlah Barang");
        model.addColumn("Harga Beli");
        model.addColumn("Kemasan");
        model.addColumn("Satuan");
        
        
        Date tanggal = new Date();
        txtTanggalTerima.setDate(tanggal);
        
        
        cmbNamaSupplier.addItem("");
        try{
         Statement stm = koneksi.createStatement();
         ResultSet rs = stm.executeQuery("select * from supplier order by NamaSupplier asc");
         rs.beforeFirst();
         while(rs.next()){
             cmbNamaSupplier.addItem(rs.getString("NamaSupplier"));
         }
         rs.close();
     }
     catch(SQLException ex)
     {
         System.out.println("Error : "+ex);
         }
        
        cmbNamaBarang.addItem("");
        try{
         Statement stm = koneksi.createStatement();
         ResultSet rs = stm.executeQuery("select * from obat order by NamaBarang asc");
         rs.beforeFirst();
         while(rs.next()){
             cmbNamaBarang.addItem(rs.getString("NamaBarang"));
         }
         rs.close();
     }
     catch(SQLException ex)
     {
         System.out.println("Error : "+ex);
         }
        
        
        cmbRuangan.addItem("");
        try{
         Statement stm = koneksi.createStatement();
         ResultSet rs = stm.executeQuery("select * from ruangan order by NamaRuangan asc");
         rs.beforeFirst();
         while(rs.next()){
             cmbRuangan.addItem(rs.getString("NamaRuangan"));
         }
         rs.close();
     }
     catch(SQLException ex)
     {
         System.out.println("Error : "+ex);
         }
        
        
        cmbSatuan.addItem("");
        try{
         Statement stm = koneksi.createStatement();
         ResultSet rs = stm.executeQuery("select * from satuanbesar order by SatuanBesar asc");
         rs.beforeFirst();
         while(rs.next()){
             cmbSatuan.addItem(rs.getString("SatuanBesar"));
         }
         rs.close();
     }
     catch(SQLException ex)
     {
         System.out.println("Error : "+ex);
         }
        
        
        setIconImage(new javax.swing.ImageIcon(getClass().getResource("/SIMRS/Apotek/gambar/icon.png")).getImage());
        setTitle(".:: Form Penerimaan Supplier");
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        pnlForm1 = new SIMRS.Apotek.widget.PnlForm();
        btnSimpan = new SIMRS.Apotek.widget.button2();
        btnTambah = new SIMRS.Apotek.widget.button2();
        btnHapus = new SIMRS.Apotek.widget.button2();
        btnBatal = new SIMRS.Apotek.widget.button2();
        btnTutup = new SIMRS.Apotek.widget.button2();
        label5 = new SIMRS.Apotek.widget.Label();
        cmbNamaSupplier = new javax.swing.JComboBox();
        label6 = new SIMRS.Apotek.widget.Label();
        label1 = new SIMRS.Apotek.widget.Label();
        txtNoOrder = new SIMRS.Apotek.widget.TextBox();
        label3 = new SIMRS.Apotek.widget.Label();
        txtNoTerima = new SIMRS.Apotek.widget.TextBox();
        label4 = new SIMRS.Apotek.widget.Label();
        txtNoFaktur = new SIMRS.Apotek.widget.TextBox();
        label7 = new SIMRS.Apotek.widget.Label();
        label9 = new SIMRS.Apotek.widget.Label();
        txtJumlah = new SIMRS.Apotek.widget.TextBox();
        label10 = new SIMRS.Apotek.widget.Label();
        txtHarga = new SIMRS.Apotek.widget.TextBox();
        label11 = new SIMRS.Apotek.widget.Label();
        txtKemasan = new SIMRS.Apotek.widget.TextBox();
        label12 = new SIMRS.Apotek.widget.Label();
        cmbSatuan = new javax.swing.JComboBox();
        scrollPane1 = new SIMRS.Apotek.widget.ScrollPane();
        tblPenerimaanSupplier = new SIMRS.Apotek.widget.Table();
        label15 = new SIMRS.Apotek.widget.Label();
        txtTanggalTerima = new com.toedter.calendar.JDateChooser();
        jPanel1 = new javax.swing.JPanel();
        label8 = new SIMRS.Apotek.widget.Label();
        txtTotal = new SIMRS.Apotek.widget.TextBox();
        label13 = new SIMRS.Apotek.widget.Label();
        txtPPN = new SIMRS.Apotek.widget.TextBox();
        label14 = new SIMRS.Apotek.widget.Label();
        txtJumlahTotal = new SIMRS.Apotek.widget.TextBox();
        satuan = new javax.swing.JTextField();
        cmbNamaBarang = new javax.swing.JComboBox();
        kdBarang = new javax.swing.JTextField();
        label16 = new SIMRS.Apotek.widget.Label();
        cmbRuangan = new javax.swing.JComboBox();
        ruangan = new javax.swing.JTextField();
        supplier = new javax.swing.JTextField();

        setTitle("Form Penerimaan Supplier");
        setAnimationHide(usu.widget.constan.Animation.SHOW_FROM_BOTTOM);
        setAnimationShow(usu.widget.constan.Animation.SHOW_FROM_TOP);
        setUndecorated(true);
        addWindowListener(new java.awt.event.WindowAdapter() {
            public void windowClosing(java.awt.event.WindowEvent evt) {
                formWindowClosing(evt);
            }
        });
        getContentPane().setLayout(new org.netbeans.lib.awtextra.AbsoluteLayout());

        pnlForm1.setBorder(new javax.swing.border.LineBorder(new java.awt.Color(57, 190, 53), 3, true));
        pnlForm1.setLayout(new org.netbeans.lib.awtextra.AbsoluteLayout());

        btnSimpan.setIcon(new javax.swing.ImageIcon(getClass().getResource("/SIMRS/Apotek/gambar/bt_simpan.png"))); // NOI18N
        btnSimpan.setText("Simpan");
        btnSimpan.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnSimpanActionPerformed(evt);
            }
        });
        pnlForm1.add(btnSimpan, new org.netbeans.lib.awtextra.AbsoluteConstraints(290, 620, -1, -1));

        btnTambah.setIcon(new javax.swing.ImageIcon(getClass().getResource("/SIMRS/Apotek/gambar/bt_tambah.png"))); // NOI18N
        btnTambah.setText("Tambah");
        btnTambah.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnTambahActionPerformed(evt);
            }
        });
        pnlForm1.add(btnTambah, new org.netbeans.lib.awtextra.AbsoluteConstraints(40, 510, -1, -1));

        btnHapus.setIcon(new javax.swing.ImageIcon(getClass().getResource("/SIMRS/Apotek/gambar/bt_hapus.png"))); // NOI18N
        btnHapus.setText("Hapus");
        btnHapus.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnHapusActionPerformed(evt);
            }
        });
        pnlForm1.add(btnHapus, new org.netbeans.lib.awtextra.AbsoluteConstraints(160, 510, -1, -1));

        btnBatal.setIcon(new javax.swing.ImageIcon(getClass().getResource("/SIMRS/Apotek/gambar/bt_batal.png"))); // NOI18N
        btnBatal.setText("Batal");
        pnlForm1.add(btnBatal, new org.netbeans.lib.awtextra.AbsoluteConstraints(410, 620, -1, -1));

        btnTutup.setIcon(new javax.swing.ImageIcon(getClass().getResource("/SIMRS/Apotek/gambar/bt_close.png"))); // NOI18N
        btnTutup.setText("Tutup");
        btnTutup.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnTutupActionPerformed(evt);
            }
        });
        pnlForm1.add(btnTutup, new org.netbeans.lib.awtextra.AbsoluteConstraints(610, 620, -1, -1));

        label5.setText("Nama Supplier");
        pnlForm1.add(label5, new org.netbeans.lib.awtextra.AbsoluteConstraints(30, 170, 100, 20));

        cmbNamaSupplier.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                cmbNamaSupplierActionPerformed(evt);
            }
        });
        pnlForm1.add(cmbNamaSupplier, new org.netbeans.lib.awtextra.AbsoluteConstraints(20, 190, 150, -1));

        label6.setText("Tanggal Terima");
        pnlForm1.add(label6, new org.netbeans.lib.awtextra.AbsoluteConstraints(220, 170, 90, 20));

        label1.setText("No Order");
        pnlForm1.add(label1, new org.netbeans.lib.awtextra.AbsoluteConstraints(360, 170, 60, 20));
        pnlForm1.add(txtNoOrder, new org.netbeans.lib.awtextra.AbsoluteConstraints(340, 190, 90, -1));

        label3.setText("No Terima");
        pnlForm1.add(label3, new org.netbeans.lib.awtextra.AbsoluteConstraints(450, 170, 60, 20));

        txtNoTerima.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                txtNoTerimaActionPerformed(evt);
            }
        });
        pnlForm1.add(txtNoTerima, new org.netbeans.lib.awtextra.AbsoluteConstraints(440, 190, 80, -1));

        label4.setText("No Faktur");
        pnlForm1.add(label4, new org.netbeans.lib.awtextra.AbsoluteConstraints(540, 170, 60, 20));

        txtNoFaktur.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                txtNoFakturActionPerformed(evt);
            }
        });
        pnlForm1.add(txtNoFaktur, new org.netbeans.lib.awtextra.AbsoluteConstraints(530, 190, 80, -1));

        label7.setText("Nama Barang");
        pnlForm1.add(label7, new org.netbeans.lib.awtextra.AbsoluteConstraints(50, 230, 90, 20));

        label9.setText("Jumlah");
        pnlForm1.add(label9, new org.netbeans.lib.awtextra.AbsoluteConstraints(260, 230, 60, 20));
        pnlForm1.add(txtJumlah, new org.netbeans.lib.awtextra.AbsoluteConstraints(240, 250, 90, -1));

        label10.setText("Harga");
        pnlForm1.add(label10, new org.netbeans.lib.awtextra.AbsoluteConstraints(350, 230, 90, 20));

        txtHarga.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                txtHargaActionPerformed(evt);
            }
        });
        pnlForm1.add(txtHarga, new org.netbeans.lib.awtextra.AbsoluteConstraints(340, 250, 120, -1));

        label11.setText("Jumlah Kemasan");
        pnlForm1.add(label11, new org.netbeans.lib.awtextra.AbsoluteConstraints(480, 230, 100, 20));

        txtKemasan.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                txtKemasanActionPerformed(evt);
            }
        });
        pnlForm1.add(txtKemasan, new org.netbeans.lib.awtextra.AbsoluteConstraints(470, 250, 120, -1));

        label12.setText("Ruangan Penerima");
        pnlForm1.add(label12, new org.netbeans.lib.awtextra.AbsoluteConstraints(630, 170, 110, 20));

        cmbSatuan.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                cmbSatuanActionPerformed(evt);
            }
        });
        pnlForm1.add(cmbSatuan, new org.netbeans.lib.awtextra.AbsoluteConstraints(600, 250, 140, -1));

        tblPenerimaanSupplier.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null}
            },
            new String [] {
                "Title 1", "Title 2", "Title 3", "Title 4"
            }
        ));
        scrollPane1.setViewportView(tblPenerimaanSupplier);

        pnlForm1.add(scrollPane1, new org.netbeans.lib.awtextra.AbsoluteConstraints(20, 300, 770, 200));

        label15.setForeground(new java.awt.Color(255, 255, 255));
        label15.setText("Penerimaan Dari Supplier");
        label15.setFont(new java.awt.Font("Tahoma", 1, 18));
        pnlForm1.add(label15, new org.netbeans.lib.awtextra.AbsoluteConstraints(30, 60, 400, -1));
        pnlForm1.add(txtTanggalTerima, new org.netbeans.lib.awtextra.AbsoluteConstraints(200, 190, 130, -1));

        jPanel1.setBackground(new java.awt.Color(0, 0, 0));
        jPanel1.setBorder(javax.swing.BorderFactory.createEtchedBorder());
        jPanel1.setOpaque(false);

        label8.setText("Total");

        label13.setText("PPN");

        label14.setText("Jumlah Total");

        satuan.setForeground(new java.awt.Color(255, 255, 51));
        satuan.setBorder(null);
        satuan.setOpaque(false);

        cmbNamaBarang.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                cmbNamaBarangActionPerformed(evt);
            }
        });

        kdBarang.setForeground(new java.awt.Color(255, 255, 51));
        kdBarang.setBorder(null);
        kdBarang.setOpaque(false);

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup()
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(jPanel1Layout.createSequentialGroup()
                                .addComponent(label8, javax.swing.GroupLayout.PREFERRED_SIZE, 30, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addGap(60, 60, 60)
                                .addComponent(txtTotal, javax.swing.GroupLayout.PREFERRED_SIZE, 120, javax.swing.GroupLayout.PREFERRED_SIZE))
                            .addGroup(jPanel1Layout.createSequentialGroup()
                                .addComponent(label13, javax.swing.GroupLayout.PREFERRED_SIZE, 30, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addGap(60, 60, 60)
                                .addComponent(txtPPN, javax.swing.GroupLayout.PREFERRED_SIZE, 120, javax.swing.GroupLayout.PREFERRED_SIZE))
                            .addGroup(jPanel1Layout.createSequentialGroup()
                                .addComponent(label14, javax.swing.GroupLayout.PREFERRED_SIZE, 80, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addGap(10, 10, 10)
                                .addComponent(txtJumlahTotal, javax.swing.GroupLayout.PREFERRED_SIZE, 120, javax.swing.GroupLayout.PREFERRED_SIZE)))
                        .addGap(27, 27, 27))
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup()
                        .addComponent(cmbNamaBarang, javax.swing.GroupLayout.PREFERRED_SIZE, 187, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 539, Short.MAX_VALUE)
                        .addComponent(satuan, javax.swing.GroupLayout.PREFERRED_SIZE, 60, javax.swing.GroupLayout.PREFERRED_SIZE))))
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addGap(185, 185, 185)
                .addComponent(kdBarang, javax.swing.GroupLayout.PREFERRED_SIZE, 110, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(501, Short.MAX_VALUE))
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(cmbNamaBarang, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(satuan, javax.swing.GroupLayout.PREFERRED_SIZE, 29, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(kdBarang, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 221, Short.MAX_VALUE)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(label8, javax.swing.GroupLayout.PREFERRED_SIZE, 20, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(txtTotal, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(6, 6, 6)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(label13, javax.swing.GroupLayout.PREFERRED_SIZE, 20, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(txtPPN, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(6, 6, 6)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(label14, javax.swing.GroupLayout.PREFERRED_SIZE, 20, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(txtJumlahTotal, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap())
        );

        pnlForm1.add(jPanel1, new org.netbeans.lib.awtextra.AbsoluteConstraints(10, 230, 800, 380));

        label16.setText("Satuan");
        pnlForm1.add(label16, new org.netbeans.lib.awtextra.AbsoluteConstraints(610, 230, 60, 20));

        cmbRuangan.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                cmbRuanganActionPerformed(evt);
            }
        });
        pnlForm1.add(cmbRuangan, new org.netbeans.lib.awtextra.AbsoluteConstraints(620, 190, 150, -1));

        ruangan.setForeground(new java.awt.Color(255, 255, 51));
        ruangan.setBorder(null);
        ruangan.setOpaque(false);
        pnlForm1.add(ruangan, new org.netbeans.lib.awtextra.AbsoluteConstraints(770, 184, 40, 20));

        supplier.setForeground(new java.awt.Color(255, 255, 51));
        supplier.setBorder(null);
        supplier.setOpaque(false);
        pnlForm1.add(supplier, new org.netbeans.lib.awtextra.AbsoluteConstraints(140, 210, 60, -1));

        getContentPane().add(pnlForm1, new org.netbeans.lib.awtextra.AbsoluteConstraints(0, 0, 820, 670));

        java.awt.Dimension screenSize = java.awt.Toolkit.getDefaultToolkit().getScreenSize();
        setBounds((screenSize.width-820)/2, (screenSize.height-668)/2, 820, 668);
    }// </editor-fold>//GEN-END:initComponents

private void txtNoTerimaActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_txtNoTerimaActionPerformed
// TODO add your handling code here:
    System.exit(1);
}//GEN-LAST:event_txtNoTerimaActionPerformed

private void txtNoFakturActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_txtNoFakturActionPerformed
// TODO add your handling code here:
}//GEN-LAST:event_txtNoFakturActionPerformed

private void txtHargaActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_txtHargaActionPerformed
// TODO add your handling code here:
}//GEN-LAST:event_txtHargaActionPerformed

private void txtKemasanActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_txtKemasanActionPerformed
// TODO add your handling code here:
}//GEN-LAST:event_txtKemasanActionPerformed

private void formWindowClosing(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_formWindowClosing
// TODO add your handling code here:
    System.exit(1);
}//GEN-LAST:event_formWindowClosing

private void btnTutupActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnTutupActionPerformed
    dispose();
}//GEN-LAST:event_btnTutupActionPerformed

private void cmbRuanganActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cmbRuanganActionPerformed
// TODO add your handling code here:
    try{
         Statement stm = koneksi.createStatement();
         ResultSet rs = stm.executeQuery("select KdRuangan from ruangan where NamaRuangan= '"+cmbRuangan.getSelectedItem().toString()+"'");
         rs.beforeFirst();
         while(rs.next()){
             ruangan.setText(rs.getString(1).trim());
         }
         rs.close();
         }
         catch(SQLException ex)
         {
             System.out.println("Error : "+ex);
             }
}//GEN-LAST:event_cmbRuanganActionPerformed

private void cmbNamaSupplierActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cmbNamaSupplierActionPerformed
// TODO add your handling code here:
    try{
         Statement stm = koneksi.createStatement();
         ResultSet rs = stm.executeQuery("select KdSupplier from supplier where NamaSupplier= '"+cmbNamaSupplier.getSelectedItem().toString()+"'");
         rs.beforeFirst();
         while(rs.next()){
             supplier.setText(rs.getString(1).trim());
         }
         rs.close();
         }
         catch(SQLException ex)
         {
             System.out.println("Error : "+ex);
             }
}//GEN-LAST:event_cmbNamaSupplierActionPerformed

private void cmbSatuanActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cmbSatuanActionPerformed
// TODO add your handling code here:
    try{
         Statement stm = koneksi.createStatement();
         ResultSet rs = stm.executeQuery("select KdSatuanBesar from satuanbesar where SatuanBesar= '"+cmbSatuan.getSelectedItem().toString()+"'");
         rs.beforeFirst();
         while(rs.next()){
             satuan.setText(rs.getString(1).trim());
         }
         rs.close();
         }
         catch(SQLException ex)
         {
             System.out.println("Error : "+ex);
             }
}//GEN-LAST:event_cmbSatuanActionPerformed

private void btnTambahActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnTambahActionPerformed
// TODO add your handling code here:
    String []a=new String[6];
        a[0]=kdBarang.getText();
        a[1]=cmbNamaBarang.getSelectedItem().toString();
        a[2]=txtJumlah.getText();
        a[3]=txtHarga.getText();
        a[4]=txtKemasan.getText();
        a[5]=cmbSatuan.getSelectedItem().toString();
        
        model.addRow(a);
        hitung_total();
}//GEN-LAST:event_btnTambahActionPerformed

private void cmbNamaBarangActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cmbNamaBarangActionPerformed
// TODO add your handling code here:
    try{
         Statement stm = koneksi.createStatement();
         ResultSet rs = stm.executeQuery("select KdBarang from obat where NamaBarang= '"+cmbNamaBarang.getSelectedItem().toString()+"'");
         rs.beforeFirst();
         while(rs.next()){
             kdBarang.setText(rs.getString(1).trim());
         }
         rs.close();
         }
         catch(SQLException ex)
         {
             System.out.println("Error : "+ex);
             }
}//GEN-LAST:event_cmbNamaBarangActionPerformed

private void btnHapusActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnHapusActionPerformed
// TODO add your handling code here:
    int row=tblPenerimaanSupplier.getSelectedRow();
    model.removeRow(row);
}//GEN-LAST:event_btnHapusActionPerformed

private void btnSimpanActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnSimpanActionPerformed
// TODO add your handling code here:
}//GEN-LAST:event_btnSimpanActionPerformed

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private SIMRS.Apotek.widget.button2 btnBatal;
    private SIMRS.Apotek.widget.button2 btnHapus;
    private SIMRS.Apotek.widget.button2 btnSimpan;
    private SIMRS.Apotek.widget.button2 btnTambah;
    private SIMRS.Apotek.widget.button2 btnTutup;
    private javax.swing.JComboBox cmbNamaBarang;
    private javax.swing.JComboBox cmbNamaSupplier;
    private javax.swing.JComboBox cmbRuangan;
    private javax.swing.JComboBox cmbSatuan;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JTextField kdBarang;
    private SIMRS.Apotek.widget.Label label1;
    private SIMRS.Apotek.widget.Label label10;
    private SIMRS.Apotek.widget.Label label11;
    private SIMRS.Apotek.widget.Label label12;
    private SIMRS.Apotek.widget.Label label13;
    private SIMRS.Apotek.widget.Label label14;
    private SIMRS.Apotek.widget.Label label15;
    private SIMRS.Apotek.widget.Label label16;
    private SIMRS.Apotek.widget.Label label3;
    private SIMRS.Apotek.widget.Label label4;
    private SIMRS.Apotek.widget.Label label5;
    private SIMRS.Apotek.widget.Label label6;
    private SIMRS.Apotek.widget.Label label7;
    private SIMRS.Apotek.widget.Label label8;
    private SIMRS.Apotek.widget.Label label9;
    private SIMRS.Apotek.widget.PnlForm pnlForm1;
    private javax.swing.JTextField ruangan;
    private javax.swing.JTextField satuan;
    private SIMRS.Apotek.widget.ScrollPane scrollPane1;
    private javax.swing.JTextField supplier;
    private SIMRS.Apotek.widget.Table tblPenerimaanSupplier;
    private SIMRS.Apotek.widget.TextBox txtHarga;
    private SIMRS.Apotek.widget.TextBox txtJumlah;
    private SIMRS.Apotek.widget.TextBox txtJumlahTotal;
    private SIMRS.Apotek.widget.TextBox txtKemasan;
    private SIMRS.Apotek.widget.TextBox txtNoFaktur;
    private SIMRS.Apotek.widget.TextBox txtNoOrder;
    private SIMRS.Apotek.widget.TextBox txtNoTerima;
    private SIMRS.Apotek.widget.TextBox txtPPN;
    private com.toedter.calendar.JDateChooser txtTanggalTerima;
    private SIMRS.Apotek.widget.TextBox txtTotal;
    // End of variables declaration//GEN-END:variables

  public void isiText(String noTerima, String noOrder, String noFaktur, String ruang, String nmBarang, String jmlhBarang, String jmlhKemasan, String nmSup, Date a, String hrgaBeli){
  txtNoTerima.setText(noTerima);
  txtNoOrder.setText(noOrder);
  txtNoFaktur.setText(noFaktur);
  cmbRuangan.setSelectedItem(ruang);
  cmbNamaBarang.setSelectedItem(nmBarang);
  txtJumlah.setText(jmlhBarang);
  txtKemasan.setText(jmlhKemasan);
  txtTanggalTerima.setDate(a);
  cmbNamaSupplier.setSelectedItem(nmSup);
  txtHarga.setText(hrgaBeli);
  
//  txtTotal.setText(tot);
  
}

  private float hitung_total(){
       
       int jml, hrga, kemasan;
       float xtot,xtot1;
       double total, hitungppn=0;
       
       xtot=0;
       xtot1=0;
       jml = Integer.parseInt(txtJumlah.getText());
       hrga=Integer.parseInt(txtHarga.getText());
       kemasan=Integer.parseInt(txtKemasan.getText());
       
       
       xtot = jml*hrga*kemasan;
       System.out.println("0 " + xtot);
       hitungppn=xtot*0.1;
       total=(xtot+(xtot*0.1));
      
        xtot1=xtot1+xtot;  
       
       for (int i = 0; i < tblPenerimaanSupplier.getRowCount(); i++) {
//         if(i==0){
           hitungppn=hitungppn+hitungppn;
           total=(xtot1+(xtot1*0.1));
           System.out.println("1 " + xtot1);
          
           
       String xppn = Double.toString(hitungppn);
       txtPPN.setText(xppn);
       
       String xjml = Float.toString(xtot1);
       txtTotal.setText(xjml);
       
       String totalakhir = Double.toString(total);
       txtJumlahTotal.setText(totalakhir);

//         }else if(i >=1){
//           xtot1=xtot1+xtot;
//           System.out.println("2 " + xtot1);
//           hitungppn=hitungppn+hitungppn;
//           total=(xtot1+(xtot1*0.1));  
//         String xppn = Double.toString(hitungppn);
//       txtPPN.setText(xppn);
//       
//       String xjml = Float.toString(xtot1);
//       txtTotal.setText(xjml);
//       
//       String totalakhir = Double.toString(total);
//       txtJumlahTotal.setText(totalakhir);
//       
    //     }
           
           
       }
     
       return xtot1;
       
        
    }

}
